/*
题目描述
Given a positive integer n (n ≤ 40), pick n − 1 numbers randomly from 1 to n and concatenate them in random order as a string s, which means there is a missing number between 1 and n. Can you find the missing number? (Notice that in some cases the answer will not be unique, and in these cases you only need to find one valid answer.)

输入格式
The input consists of two lines:
  - The first line contains the integer n .
  - The second line contains the string s formed by concatenating n − 1 numbers.
输出格式
Output the missing number.

输入样例
20
281971112205101569183132414117
输出样例
16
*/
#include <bits/stdc++.h>
using namespace std;

int n;
string s;
vector<bool> used;
bool found = false;
int missingNumber = -1;

void dfs(int index, int count) {
    if (found) return; // 已找到答案，直接返回

    // 如果所有字符都用完
    if (index == s.size()) {
        if (count == n - 1) { // 确认只缺一个数字
            for (int i = 1; i <= n; i++) {
                if (!used[i]) {
                    missingNumber = i;
                    found = true;
                    return;
                }
            }
        }
        return;
    }

    // 尝试切 1 位或 2 位
    for (int len = 1; len <= 2; len++) {
        if (index + len > s.size()) break;
        int num = stoi(s.substr(index, len));
        if (num < 1 || num > n || used[num]) continue;
        used[num] = true;
        dfs(index + len, count + 1);
        used[num] = false;
    }
}

int main() {
    cin >> n >> s;
    used.assign(n + 1, false);

    dfs(0, 0);

    if (missingNumber != -1)
        cout << missingNumber << endl;
    else
        cout << "无法确定唯一缺失数字" << endl;

    return 0;
}
